﻿/**	\file		lxprofile.hxx
 *	\date		(2014-11-17 23:33:33)/(2014-11-17 23:33:33)
 *-----------------------------------------------------------------------------
 *	\brief
 *	\version	1.0.0.1
 *	\author		Nick Shallery	(nicknide@gmail.com)
 *	\copyright	YOU HAVE ALL LEFT WITH THIS CODE WHILE YOU KEEP COMMENT IN EVERY COPY.
 *-----------------------------------------------------------------------------
**/

#if			!defined(__LOLIX__PROFILE__LX_PREF__H__NICK__K_IN_G__)
	#include	"./lxpref.h"
#endif	//	!defined(__LOLIX__PROFILE__LX_PREF__H__NICK__K_IN_G__)

#if			!defined(__LOLIX__LOLI__CRITICAL_SECTION__K_IN_G__)
	#include	<lolix/loli/critical_section.h>
#endif	//	!defined(__LOLIX__LOLI__CRITICAL_SECTION__K_IN_G__)

#if			!defined(__LOLIX__LOLI__THREAD__NICK__K_IN_G__)
	#include	<lolix/loli/thread.h>
#endif	//	!defined(__LOLIX__LOLI__THREAD__NICK__K_IN_G__)

#if			!defined(__LOLIX__TOY__STD_MAP__NICK__K_IN_G__)
	#include	<lolix/toy/std_map.hpp>
#endif 	//	!defined(__LOLIX__TOY__STD_MAP__NICK__K_IN_G__)

#if			!defined(__LOLIX__TOY__STD_STRING__NICK__K_IN_G__)
	#include	<lolix/toy/std_string.hpp>
#endif	//	!defined(__LOLIX__TOY__STD_STRING__NICK__K_IN_G__)

#if			!defined(__LOLIX__TOY__FIFO_QUEUE__HPP__NICK__K_IN_G__)
	#include	<lolix/toy/fifo_queue.hpp>
#endif	//	!defined(__LOLIX__TOY__FIFO_QUEUE__HPP__NICK__K_IN_G__)

#if			!defined(__LOLIX__TOY__ALIGN__HPP__NICK__K_IN_G__)
	#include	<lolix/toy/align.hpp>
#endif	//	!defined(__LOLIX__TOY__ALIGN__HPP__NICK__K_IN_G__)

#if			!defined(__LOLIX__LX_MEM__POOL__HXX__NICK__K_IN_G__)
	#include	"./lxmem_pool.hxx"
#endif	//	!defined(__LOLIX__LX_MEM__POOL__HXX__NICK__K_IN_G__)

namespace lxpref{namespace _inst{
	class lxprofile_inst
		: public lolix::itf_Tbase<lxprofile_inst, lxprofile>
	{
		LOLIX_DEFINE_ITF(lxpref::_inst::lxprofile_inst, lxpref::lxprofile, (0xe379ce6d, 0xc9be4e6f, 0x9240c01d, 0x407f1b76));
		typedef lolix::toy::basic_string<lolix::lx_wchar, void, allocator_type> WSTRING;
		typedef MemPool<event_info, allocator_type> _DatAlc;

		lolix::dynamic_allocator*		_alc;
		lolix::loli::critical_section*	_cs;
		lolix::toy::time_info*			_tinf;
		lolix::loli::thread_factory*	_td_fac;
		lolix::loli::signal*			_sign;
		mutable lolix::toy::map<WSTRING, size_type, WSTRING::quick_compare, allocator_type> _mem_map;
		lolix::toy::fifo_queue<event_info, lolix::THREAD_SAFE_SRMW, _DatAlc> _dat;
		lxprofile_inst(lolix::loli::signal* sign, lolix::dynamic_allocator* alc);
		~lxprofile_inst(void);
	public:
		static LOLIX_RETNV create_inst(this_type** out_ptr, lolix::dynamic_allocator* alc, lolix::ref_factory* ref_fac, lolix::toy::time_info* tinf, lolix::loli::cs_factory* cs_fac, lolix::loli::signal::factory_type* sign_fac, lolix::loli::thread_factory* td_fac);
		LOLIX_INTERFACE_DEF(touch, void, (lolix::lx_u32 eventFlag, size_type name_len, const lolix::lx_wchar** name_arr));
		LOLIX_INTERFACE_DEF(new_string, const lolix::lx_wchar*, (const lolix::lx_wchar* name)const);
		LOLIX_INTERFACE_DEF(free_string, void, (const lolix::lx_wchar* name)const);
		LOLIX_INTERFACE_DEF(peek_node, LOLIX_RETNV, (event_info** evt_info));
		LOLIX_INTERFACE_DEF(free_node, LOLIX_RETNV, (event_info* evt_info));
		LOLIX_INTERFACE_DEF(wait_node, LOLIX_RETNV, (lolix::toy::time_span const* ts)const);
		LOLIX_INTERFACE_DEF(query_signal, LOLIX_RETNV, (lolix::loli::signal** out_signal));
	private:
		static void __Init_cnt_table(void);
	};
}}
